package com.rephilo.sqlSession;

import com.rephilo.config.XMLConfigBuilder;
import com.rephilo.pojo.Configuration;
import org.dom4j.DocumentException;

import java.io.InputStream;

/**
 * @author rephilo
 */
public class SqlSessionFactoryBuilder {
    public SqlSessionFactory build(InputStream in) throws DocumentException {
        //使用dom4j 解析配置文件，封装到Configuration类中
        XMLConfigBuilder xmlConfigBuilder = new XMLConfigBuilder();
        Configuration configuration = xmlConfigBuilder.parseConfig(in);

        //创建sqlSessionFactory
        return new DefaultSqlSessionFactory(configuration);
    }
}
